package com.ruoyi.system.neu.wclass.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.domain.entity.WClass;
import com.ruoyi.system.neu.wclass.service.IWClassService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 班组管理Controller
 * 
 * @author wxd
 * @date 2023-01-05
 */
@RestController
@RequestMapping("/system/class")
public class WClassController extends BaseController
{
    @Autowired
    private IWClassService wClassService;

    /**
     * 查询班组管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:class:list')")
    @GetMapping("/list")
    public TableDataInfo list(WClass wClass)
    {
        startPage();
        List<WClass> list = wClassService.selectWClassList(wClass);
        return getDataTable(list);
    }

    /**
     * 导出班组管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:class:export')")
    @Log(title = "班组管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WClass wClass)
    {
        List<WClass> list = wClassService.selectWClassList(wClass);
        ExcelUtil<WClass> util = new ExcelUtil<WClass>(WClass.class);
        return util.exportExcel(list, "class");
    }

    /**
     * 获取班组管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:class:query')")
    @GetMapping(value = "/{classId}")
    public AjaxResult getInfo(@PathVariable("classId") Long classId)
    {
        return AjaxResult.success(wClassService.selectWClassById(classId));
    }

    /**
     * 新增班组管理
     */
    @PreAuthorize("@ss.hasPermi('system:class:add')")
    @Log(title = "班组管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WClass wClass)
    {
        return toAjax(wClassService.insertWClass(wClass));
    }

    /**
     * 修改班组管理
     */
    @PreAuthorize("@ss.hasPermi('system:class:edit')")
    @Log(title = "班组管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WClass wClass)
    {
        return toAjax(wClassService.updateWClass(wClass));
    }

    /**
     * 删除班组管理
     */
    @PreAuthorize("@ss.hasPermi('system:class:remove')")
    @Log(title = "班组管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{classIds}")
    public AjaxResult remove(@PathVariable Long[] classIds)
    {
        return toAjax(wClassService.deleteWClassByIds(classIds));
    }
}
